package com.whl.sm.service.impl.parking;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whl.sm.common.result.Result;
import com.whl.sm.mapper.parking.ParkingLotsMapper;
import com.whl.sm.model.parking.ParkingLots;
import com.whl.sm.service.parking.ParkingLotsService;
import com.whl.sm.service.system.OrgUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wuhaolun
 * @since 2021-10-25
 */
@Slf4j
@Service
public class ParkingLotsServiceImpl extends ServiceImpl<ParkingLotsMapper, ParkingLots> implements ParkingLotsService {

    @Autowired
    private OrgUserService orgUserService;

    @Override
    public Result update(ParkingLots parkingLots) {
         try{
             parkingLots.setOperator(orgUserService.getCurrentUserId());
             if (parkingLots.getId() != null){
                 getBaseMapper().updateById(parkingLots);
             }else {
                 getBaseMapper().insert(parkingLots);
             }
             return Result.ok();
         }catch (Exception e) {
             log.error("停车管理-->停车场管理:更新操作失败！----" + e.getMessage());
             return Result.fail();
         }
    }
}
